package cn.pms.po;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import cn.pms.type.EmployeeState;
import cn.pms.type.Role;

/**
 * Employee entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_employee", schema = "SCOTT")
public class Employee implements java.io.Serializable
{
	private static final long serialVersionUID = -8633450250875056897L;
	// Fields
	private Integer id;
	private Department department;
	private String name;
	private String password;
	private Role role;
	private EmployeeState empState;
	private Boolean isLogin;
	private String remark;
	private Set<Message> messages = new HashSet<Message>(0);
	private Set<Check> checks = new HashSet<Check>(0);
	
	// Constructors
	/** default constructor */
	public Employee()
	{}
	
	/** minimal constructor */
	public Employee(Department department, String name, String password,
			Role role, EmployeeState empState, Boolean isLogin)
	{
		this.department = department;
		this.name = name;
		this.password = password;
		this.role = role;
		this.empState = empState;
		this.isLogin = isLogin;
	}
	
	/** full constructor */
	public Employee(Department department, String name, String password,
			Role role, EmployeeState empState, Boolean isLogin, String remark,
			Set<Message> messages, Set<Check> checks)
	{
		this.department = department;
		this.name = name;
		this.password = password;
		this.role = role;
		this.empState = empState;
		this.isLogin = isLogin;
		this.remark = remark;
		this.messages = messages;
		this.checks = checks;
	}
	
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, precision = 32, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_EMP")
	@SequenceGenerator(name = "SEQ_EMP", sequenceName = "SEQ_EMP", allocationSize = 1)
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "depId", nullable = false)
	public Department getDepartment()
	{
		return this.department;
	}
	
	public void setDepartment(Department department)
	{
		this.department = department;
	}
	
	@Column(name = "name", nullable = false, length = 100)
	public String getName()
	{
		return this.name;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	@Column(name = "password", nullable = false, length = 100)
	public String getPassword()
	{
		return this.password;
	}
	
	public void setPassword(String password)
	{
		this.password = password;
	}
	
	@Column(name = "role", nullable = false, length = 100)
	@Enumerated(EnumType.STRING)
	public Role getRole()
	{
		return this.role;
	}
	
	public void setRole(Role role)
	{
		this.role = role;
	}
	
	@Column(name = "empState", nullable = true)
	@Enumerated(EnumType.STRING)
	public EmployeeState getEmpState()
	{
		return this.empState;
	}
	
	public void setEmpState(EmployeeState empState)
	{
		this.empState = empState;
	}
	
	@Column(name = "isLogin", nullable = true)
	public void setIsLogin(Boolean isLogin)
	{
		this.isLogin = isLogin;
	}
	
	public Boolean getIsLogin()
	{
		return isLogin;
	}
	
	@Column(name = "remark", length = 500)
	public String getRemark()
	{
		return this.remark;
	}
	
	public void setRemark(String remark)
	{
		this.remark = remark;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employee")
	public Set<Message> getMessages()
	{
		return this.messages;
	}
	
	public void setMessages(Set<Message> messages)
	{
		this.messages = messages;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "employee")
	public Set<Check> getChecks()
	{
		return this.checks;
	}
	
	public void setChecks(Set<Check> checks)
	{
		this.checks = checks;
	}
}
